import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
class TestUntitled1:
    '进入租户注册页面'
    def test_untitled_a(self, driver):
        # 点击注册
        driver.get("https://test.hjhrcloud.com/mh/home")
        driver.maximize_window()
        address = driver.find_element(By.XPATH, '//*[@id="app"]/section/header/div/div/div[3]/div[1]/div/span/button/span')
        actions = ActionChains(driver)
        actions.move_to_element(address).perform()
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR,".el-dropdown-menu__item:nth-child(1)")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR,".el-dropdown-menu__item:nth-child(1)")))
        driver.find_element(By.CSS_SELECTOR,".el-dropdown-menu__item:nth-child(1)").click()

    '进入服务商注册页面'
    def test_untitled_b(self, driver):
        # 点击注册
        driver.get("https://test.hjhrcloud.com/mh/home")
        driver.maximize_window()
        address = driver.find_element(By.XPATH,'//*[@id="app"]/section/header/div/div/div[3]/div[1]/div/span/button/span')
        actions = ActionChains(driver)
        actions.move_to_element(address).perform()
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(3)")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(3)")))
        driver.find_element(By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(3)").click()

    '进入个人注册页面'
    def test_untitled_c(self, driver):
        # 点击注册
        driver.get("https://test.hjhrcloud.com/mh/home")
        driver.maximize_window()
        address = driver.find_element(By.XPATH,'//*[@id="app"]/section/header/div/div/div[3]/div[1]/div/span/button/span')
        actions = ActionChains(driver)
        actions.move_to_element(address).perform()
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(2)")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(2)")))
        driver.find_element(By.CSS_SELECTOR, ".el-dropdown-menu__item:nth-child(2).el-dropdown-menu__item:nth-child(2)").click()

    '209用例：点击租户注册，输入正确的邮箱，进行注册会跳转到第二步' \
    '211用例：点击服务商注册，输入正确的邮箱，进行注册会跳转到第二步'
    def test_untitled1(self, driver,name):
        # 输入邮箱
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH, "//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH, "//input")))
        driver.find_element(By.XPATH, "//input").send_keys(name)
        # 点击注册
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH, "//div[2]/div[2]/div[2]/div")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH, "//div[2]/div[2]/div[2]/div")))
        result = driver.find_element(By.XPATH, "//div[2]/div[2]/div[2]/div").text
        return result

    '210用例：点击租户注册，输入错误邮箱/特殊字符，进行注册会提示：输入正确的邮箱' \
    '212用例：点击服务商注册，输入错误邮箱/特殊字符，进行注册会提示：输入正确的邮箱'
    def test_untitled2(self, driver,name):
        # 输入邮箱
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH,"//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH,"//input")))
        driver.find_element(By.XPATH,"//input").send_keys(name)
        # 点击注册
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR, ".el-form-item__error")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-form-item__error")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-form-item__error").text
        return result

    '214用例：点击租户注册，输入已经注册过的的邮箱，会提示：您的邮箱已注册成宏景云用户/服务商，可以用邮箱作为账号登录！' \
    '213用例：点击服务商注册，输入已经注册过的的邮箱，会提示：您的邮箱已注册成宏景云用户/服务商，可以用邮箱作为账号登录！' \
    '215用例：点击服务商注册，输入未激活的的邮箱，会提示： 您的邮箱尚未激活成为宏景云用户，点击注册重新获取链接！'
    def test_untitled3(self, driver,name):
        # 输入邮箱
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH, "//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH, "//input")))
        driver.find_element(By.XPATH, "//input").send_keys(name)
        # 点击注册
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR, ".el-message__content")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-message__content")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-message__content").text
        return result

    '219用例：点击租户注册时，不输入邮箱，点击注册时会提示：请输入邮箱' \
    '220用例：点击服务商注册时，邮箱输入框为空时，点击注册会提示：请输入邮箱'
    def test_untitled4(self, driver):
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR,'.btn-submit')
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.btn-submit')))
        # 点击注册
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.001)
        located = (By.CSS_SELECTOR, ".el-message__content")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.001).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-message__content")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-message__content").text
        return result

    '217用例：点击个人注册，输入特殊字符的单位注册码，进行注册会提示：请输入字母或数字'
    def test_untitled5(self, driver,name):
        # 输入单位注册码
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH,"//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH,"//input")))
        driver.find_element(By.XPATH,"//input").send_keys(name)
        # 点击下一步
        driver.find_element(By.CSS_SELECTOR,'.el-form').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR, ".el-form-item__error")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-form-item__error")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-form-item__error").text
        return result

    '218用例：单位注册码框为空时，会提示：请输入单位注册码'
    def test_untitled6(self, driver):
        # 点击下一步
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.CSS_SELECTOR,'.btn-submit')
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.btn-submit')))
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.001)
        located = (By.CSS_SELECTOR, ".el-form-item__error")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.001).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-form-item__error")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-form-item__error").text
        return result

    '221用例：点击个人注册，输入错误的单位注册码，提示：单位不存在' \
    '223用例：点击个人注册，输入中文，进行注册会提示：请输入字母或数字'
    def test_untitled7(self, driver,name):
        # 输入单位注册码
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH,"//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH,"//input")))
        driver.find_element(By.XPATH,"//input").send_keys(name)
        # 点击下一步
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        driver.implicitly_wait(10)
        # 获取实际结果
        wait = WebDriverWait(driver, 10, 0.001)
        located = (By.CSS_SELECTOR, ".el-message")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.001).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".el-message")))
        result = driver.find_element(By.CSS_SELECTOR, ".el-message").text
        return result

    '222用例：点击个人注册，输入存在的单位注册码，会跳转到二级域名：http://12.hjypt.com/account/register?web=1'
    def test_untitled8(self, driver,name):
        # 输入单位注册码
        wait = WebDriverWait(driver, 10, 0.01)
        located = (By.XPATH,"//input")
        conditions = EC.visibility_of_element_located(located)
        wait.until(conditions)
        WebDriverWait(driver, 10, 0.01).until(EC.visibility_of_element_located((By.XPATH,"//input")))
        driver.find_element(By.XPATH,"//input").send_keys(name)
        # 点击下一步
        driver.find_element(By.CSS_SELECTOR,'.btn-submit').click()
        time.sleep(1)
        # 获取实际结果
        result = driver.current_url
        return result
